package cn.gok.day2;

/**
 * @ClassName Test
 * @Description TODO
 * @Author HP
 * @Date 9:56 2022/7/5
 * @Version 1.0
 **/
public class Test {
    public static void main(String[] args) {

//        study("Oscar","男",22);
//        Child child=new Child(1,2,3);
//        System.out.println(child.getSum());
//        Fly fly=new Dog();
//        fly.fly();
//        Dog dog=new Dog();
//        dog.eat();
//        dog.fly();
//        Anm cat=new Cat();
//        cat.eat();
//        cat.shup();
Test test=new Test();
        System.out.println("被重载的方法add："+test.add(2));
        System.out.println("重载的方法add："+test.add(2,3));

    }

public static class StringTool{
        private static String VERSION="V1.0";
        private int x;
        private int y;
//        将字符串中的字母大小写互换，其他不变
    public static String change(String str){
        String tp[]=str.split("");
        for (String t:tp) {
            System.out.print(t);
        }
        return str;
    }
}
     int age;
     String sex;
     String name;
    public void show(){
        System.out.println(name+" "+sex+" "+age);
    }
    public static void study(String name,String sex,int age){
        Test test=new Test();
        test.name=name;
        test.sex=sex;
        test.age=age;
        test.show();
        System.out.println(test.toString());;
    }
public int add(int i){
        return i++;
}
public int add(int i,int n){
    for (int j = 0; j < n; j++) {
        i++;
    }
    return i;
}
    @Override
    public String toString() {
        return "Test{" +
                "age=" + age +
                ", sex='" + sex + '\'' +
                ", name='" + name + '\'' +
                '}';
    }



    public Test() {
    }

    public Test(int age, String sex, String name) {
        this.age = age;
        this.sex = sex;
        this.name = name;
    }
//    继承:值得一提的是，不加static的话会报错的哦
public static class Parent{
        private int x;
        private int y;

    public Parent() {
    }

    public Parent(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    @Override
    public String toString() {
        return "Parent{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
}
    public static class Child extends Parent{
        private int z;
     public Child() {
     }
    public Child(int z) {
        this.z = z;
    }

    public Child(int x, int y, int z) {
        super(x, y);
        this.z = z;
    }
    public int getSum(){
        return this.getX()+this.getY()+z;
    }


}
interface Fly{
        public void fly();
}
interface Eat{
        public void eat();
}
interface Shup{
        public void shup();
}
interface Anm extends Shup,Eat{
//        继承其他两个接口
}
    public static class Cat implements Anm{

        @Override
        public void eat() {
            System.out.println("猫咪在叫！");

        }

        @Override
        public void shup() {
            System.out.println("猫咪在睡觉！");

        }
    }
public static class Dog implements Fly,Eat{

    @Override
    public void fly() {
        System.out.println("狗狗在叫！");
    }

    @Override
    public void eat() {
        System.out.println("狗狗在吃东西！");
    }
}
}
